PUBLIC SUB ButtonFind_Click
()
DIM
c AS String
DIM
result AS Integer
DIM
patterns AS NEW String [ ]
DIM
pattern_number AS Integer
pattern_number =
0
patterns
=
Split ( Upper $ (
TextBoxFilter. text ), "" )
pattern_number =
patterns. COUNT
IF
pattern_number =
0
THEN
patterns. Resize
( 3
)
patterns [ 0
] =
"*"
patterns [ 1
] =
""
patterns [ 2
] =
""
ENDIF
IF
pattern_number =
1
THEN
patterns. Resize
( 3
)
patterns [ 1
] =
""
patterns [ 2
] =
""
ENDIF
IF
pattern_number =
2
THEN
patterns. Resize
( 3
)
patterns [ 2
] =
""
ENDIF
IF
pattern_number> 3
THEN
Message. info
( "maximum is 3 search patterns"
)
TextBoxFind. SetFocus
GOTO
EndFilter
ENDIF
result
=
filter. ConceptFilter
(patterns [ 0
], patterns [ 1
], patterns [ 2
])
IF
RESULT =
1
THEN
gridViewData. Background
=
Color. cyan
ELSE
gridViewData. Background
=
Color. White
ENDIF
EndFilter:
END
PUBLIC FUNCTION ConceptFilter(pattern
AS String,
OPTIONAL
pattern1 AS String, OPTIONAL
pattern2 AS String) AS Integer
DIM sLine AS String
DIM
a AS Integer
DIM
number AS Integer
DIM
validate AS Boolean
fmain.
gridViewData
. Rows
. COUNT
=
0
count =
0
'valid file counter (not suppressed)
IF
pattern =
"*"
OR
pattern =
""
THEN
'fill all datafields
title. fill
()
RETURN 0
ENDIF
IF
pattern1 =
""
THEN
pattern1 =
""
IF
pattern2 =
""
THEN
pattern2 =
""
FOR
a =
0
TO
var. id
. COUNT
-
1
sLine =
""
sLine &
=
var. id
[a]
sLine &
=
var. dni
[a]
sLine &
=
var. name
[s]
sLine &
=
var. surname
[a]
sLine &
=
var. Company
[a]
sLine &
=
var. position[a]
sLine &
=
var. tel_Company
[a]
sLine &
=
var. tel_Private
[a]
sLine &
=
var. fax
[a]
sLine &
=
var. mobile_Company
[a]
sLine &
=
var. mobile_Private
[a]
sLine &
=
var. page
[a]
sLine &
=
var. photo
[a]
sLine &
=
var. address
[a]
sLine &
=
var. Comments
[a]
sLine &
=
var. Data_date
[a]
sLine &
=
var. mail
[a]
sLine =
Upper
$ ( sLine )
valid = in
( sLine, pattern) AND in ( sLine, pattern1 )
AND in ( sLine, pattern2 )
IF
valid THEN
number + =
1
FMain. gridViewData
. Row s
. COUNT
=
number
WITH
FMain
. GridViewData
[number -
1
, 0
]. Picture
=
Picture [var. photo
[a]]
. GridViewData
[number -
1
, 1
]. text
=
var. name
[s]
. GridViewData
[number -
1
, 2
]. text
=
var. surname
[a]
. GridViewData
[number -
1
, 3
]. text
=
var. dni
[a]
. GridViewData
[number -
1
, 4
]. text
=
var. Company
[a]
. GridViewData
[number -
1
, 5
]. text
=
var. position
[a]
. GridViewData
[number -
1
, 6
]. text
=
var. tel_Company
[a]
. GridViewData
[number -
1
, 7
]. text
=
var. mobile_Company
[a]
. GridViewData
[number -
1
, 8
]. text
=
var. tel_private
[a]
. GridViewData
[number -
1
, 9
]. text
=
var. mobile_private
[a]
. GridViewData
[number -
1
, 10
]. text
=
var. fax
[a]
. GridViewData
[number -
1
, 11
]. text
=
var. mail
[a]
. GridViewData
[number -
1
, 12
]. text
=
var. page
[a]
. GridViewData
[number -
1
, 13
]. text
=
var. address
[a]
. GridViewData
[number -
1
, 14
]. text
=
var. Comments
[a]
. GridViewData
[number -
1
, 15
]. text
=
var. Data_date
[a]
. GridViewData
[number -
1
, 16
]. text
=
var. id
[a]
END WITH
ENDIF
NEXT
IF count > 0
THEN
'DUPLICATE FUNCTION
RETURN
1
ELSE
RETURN 0
ENDIF
END
'-----------------------------------------------------
'Function in
'-----------------------------------------------------
SUB
in (phrase AS String
, pattern AS String ) AS Boolean
IF
pattern =
"" THEN
RETURN
1
ELSE
RETURN InStr (
phrase, pattern )
ENDIF
END